package com.util.textProcess;

import java.io.UnsupportedEncodingException;

import com.sun.jna.Library;
import com.sun.jna.Native;

public class NLPIR {
	// static String
	// path="C:\\Users\\Yu\\Workspaces\\MyEclipse 2015\\CrawlInfo\\file\\";
	// static String path=System.getProperty("user.dir")+"\\file\\";
	static String path = "D:\\Workspaces\\MyEclipse 2015\\.metadata\\.me_tcat7\\webapps\\HealthManager\\file\\";
	public static String stopWordPath = path + "\\StopWord.txt";
	private static CLibrary instance = null;

	/**
	 * ��дNLPIR�ӿ�
	 * 
	 * @author Yu
	 *
	 */
	public interface CLibrary extends Library {
		// CLibrary Instance=(CLibrary)
		// Native.loadLibrary(path+"NLPIR",CLibrary.class);
		// 初始化NLPIR
		public int NLPIR_Init(String sDataPath, int encoding,
				String sLicenceCode);

		// 分词
		public String NLPIR_ParagraphProcess(String sSrc, int bPOSTagged);

		// 提取关键词
		public String NLPIR_GetKeyWords(String sLine, int nMaxKeyLimit,
				boolean bWeightOut);

		// 获取指纹值ֵ
		public long NLPIR_FingerPrint(String sLine);

		// 退出NLPIR
		public void NLPIR_Exit();

		// 停用词处理
		public int NLPIR_ImportKeyBlackList(String stopWordPath);
	}

	public static CLibrary getInstance() {
		if (instance == null) {
			instance = (CLibrary) Native.loadLibrary(path + "NLPIR",
					CLibrary.class);
		}
		return instance;
	}

	/**
	 * ��ʼ��NLPIR
	 * 
	 * @param args
	 * @throws UnsupportedEncodingException
	 */
	public static int init_NLPIR() throws UnsupportedEncodingException {
		// String system_charset="GBK";
		CLibrary instance = getInstance();
		int init_flag = instance.NLPIR_Init(path, 1, "0");
		return init_flag;
	}
}
